package com.xxzuibang.day16.日期类;

import java.util.Calendar;
import java.util.GregorianCalendar;

public class Calendar_ {
    public static void main(String[] args) {
        Calendar c=Calendar.getInstance();
        System.out.println("c="+c);
        //获取日历对象的某个日历字段
        System.out.println("年："+c.get(Calendar.YEAR));
        //返回月的时候从0开始计算
        System.out.println("月:"+(c.get(Calendar.MONTH)+1));
        System.out.println("日："+c.get(Calendar.DAY_OF_MONTH));
        System.out.println("时:"+c.get(Calendar.HOUR));
        System.out.println("分："+c.get(Calendar.MINUTE));
        System.out.println("秒"+c.get(Calendar.SECOND));
        //组合展示
        System.out.println(c.get(Calendar.YEAR)+"-"+(c.get(Calendar.MONTH)+1)+"-"+c.get(Calendar.DAY_OF_MONTH)+" "
        +c.get(Calendar.HOUR)+":"+c.get(Calendar.MINUTE)+":"+c.get(Calendar.SECOND));
    }
}
